package com.mp.domain;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Codce {

    static int  f(String str1,String  str2){
      if(str1 == null || str2 == null){
          return 0;
      }
       return f_m2(str1.toCharArray(),str2.toCharArray(),0,0,0);

    }
    static int f_m2(char[] chars1, char[] chars2,int index,int step,int L){
        if(index >= chars1.length){
            return 0;
        }
        if(chars1[index] == chars2[step]){
            return 1;
        }else{
            f_m2(chars1,chars2,index+1,step,L);
        }

        return L;
    }
    static int f_m(String str1,String str2){
        char[] chars1 = str1.toCharArray();
        char[] chars2 = str2.toCharArray();
        List<Character> sets=new ArrayList<>();

        int step=0;
        for (int i=0;i<chars1.length;i++) {
            for (int j=step;j<chars2.length;j++) {
                if( chars1[i] == chars2[j]  ){
                    step=j;
                    sets.add(chars1[i]);
                    break;
                }
            }
        }
        System.out.println(sets.toString());
        return  sets.size();
    }

    public static void main(String[] args) {
        System.out.println(f("a123","adsad"));
    }

}
